<#setting number_format="0" /> 
<#if (type?? && type == "view")>
	<#if (provinceValue??)>
	<span>
		${provinceValue!""}<#if (cityValue??)>/${cityValue!""}<#if (townValue??)>/${townValue!""}</#if></#if>
	</span>
	</#if>
<#else>
<#if (provinceName?? && cityName?? && townName??)>
	<select name="${provinceName}" id="${provinceId}">
		<option value="">请选择</option>
		<#if provinces??>
		<#list provinces as region>
		<option value="${region.code}" <#if (provinceValue?? && region.code?string == provinceValue)>selected="selected"</#if>>${region.name}</option>
		</#list>
		</#if>
	</select>
	<select name="${cityName}" id="${cityId}">
		<option value="">请选择</option>
		<#if citys??>
		<#list citys as region2>
		<option value="${region2.code}" <#if (cityValue?? && region2.code?string == cityValue)>selected="selected"</#if>>${region2.name}</option>
		</#list>
		</#if>
	</select>
	<select name="${townName}" id="${townId}">
		<option value="">请选择</option>
		<#if towns??>
		<#list towns as region3>
		<option value="${region3.code}"  <#if (townValue?? && region3.code?string == townValue)>selected="selected"</#if>>${region3.name}</option>
		</#list>
		</#if>
	</select>
	<script type="text/javascript">
	  $("#${provinceId}").change(function()
	   {
		   	$.ajax({
		               type: "POST",
		               url: "${request.getContextPath()}/ajaxRegion/getCitys.action",
		               data: {"code" : $(this).val()},
		               dataType: "json",
		               success: function(data) 
		               {
		               		$("#${cityId}").empty();
		               		
		               		$("#${cityId}").append("<option value=''>请选择</option");
		               		
		               		$("#${townId}").empty();
		               		
		               		$("#${townId}").append("<option value=''>请选择</option");
		               		
		               		var regions = data.regions;
							if(regions.length == 0)
							{
								$("#${cityId}").hide();
								$("#${townId}").hide();
							}
							else
							{
								$("#${cityId}").show();
							    $("#${townId}").show();
							    
			               		for (var i = 0; i < regions.length; i++)
			               		{
			               			$("#${cityId}").append("<option value='"+ regions[i].code +"'>"+ regions[i].name +"</option>");
			               		}
		               		}
		               		
					   },
					   error: function()
					   {
					   
					   }
		           })
	    });
	    $("#${cityId}").change(function()
	   {
		   	$.ajax({
		               type: "POST",
		               url: "${request.getContextPath()}/ajaxRegion/getTowns.action",
		               data: "code=" + $(this).val(),
		               dataType: "json",
		               success: function(data) 
		               {
		               	    $("#${townId}").empty();
		               		
		               		$("#${townId}").append("<option value=''>请选择</option");
		               		
		               		var regions = data.regions;
		               		
		               		if(regions.length == 0)
		               		{
		               			$("#${townId}").hide();
		               		}
		               		else
		               		{
		               			$("#${townId}").show();
		               			
			               		for (var i = 0; i < regions.length; i++)
			               		{
			               			$("#${townId}").append("<option value='"+ regions[i].code +"'>"+ regions[i].name +"</option>");
			               		}
		               		}
		               		
					   },
					   error: function()
					   {
					   
					   }
		           })
	    });
	   </script>
	   </#if>
</#if>